{% load adminmedia %}
<form id="the_{{ prefix }}_form" method="post" {% if host.id %} action="{% url modify_host host.id %}" {% endif %} >
  {% csrf_token %}
  <div>
    <fieldset style="float:left;">
      {{ form.non_field_errors }}
        <table  class="clariadmin_form better">
            <tr>
                <th>{{ form.site.label_tag }}</th><td class="no_border">{{ form.site }}</td><td class="no_border">{{ form.site.errors }}</td>
                <td>
                    {% if perms.common.add_client %}
                    <a id='add_id_{{ form.site.name }}' class="add-another" href="{% url admin:common_client_add %}" onclick="return showAddAnotherPopup(this);">
                        <img width="10" height="10" alt="Ajouter un autre" src="{% admin_media_prefix %}img/admin/icon_addlink.gif" />
                    </a>{% endif %}
                </td>
            </tr>
            <tr>
                <th>{{ form.hostname.label_tag }}</th><td class="no_border">{{ form.hostname }}</td><td class="no_border">{{ form.hostname.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.ip.label_tag }}</th><td class="no_border">{{ form.ip }}</td><td class="no_border">{{ form.ip.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.os.label_tag }}</th><td class="no_border">{{ form.os }}</td><td class="no_border">{{ form.os.errors }}</td>
                <td>
                    {% if perms.clariadmin.add_supplier %}
                    <a id='add_id_{{ form.os.name }}' class="add-another" href="{% url admin:clariadmin_operatingsystem_add %}" onclick="return showAddAnotherPopup(this);">
                        <img width="10" height="10" alt="Ajouter un autre" src="{% admin_media_prefix %}img/admin/icon_addlink.gif" />
                    </a>{% endif %}
                </td>
            </tr>
            <tr>
                <th>{{ form.rootpw.label_tag }}</th><td class="no_border">{{ form.rootpw }}</td><td class="no_border">{{ form.rootpw.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.supplier.label_tag }}</th><td class="no_border">{{ form.supplier }}</td><td class="no_border">{{ form.supplier.errors }}</td>
                <td>
                    {% if perms.clariadmin.add_supplier %}
                    <a id='add_id_{{ form.supplier.name }}' class="add-another" href="{% url admin:clariadmin_supplier_add %}" onclick="return showAddAnotherPopup(this);">
                        <img width="10" height="10" alt="Ajouter un autre" src="{% admin_media_prefix %}img/admin/icon_addlink.gif" />
                    </a>{% endif %}
                </td>
            </tr>
            <tr>
                <th>{{ form.model.label_tag }}</th><td class="no_border">{{ form.model }}</td><td class="no_border">{{ form.model.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.type.label_tag }}</th><td class="no_border">{{ form.type }}</td><td class="no_border">{{ form.type.errors }}</td>
                <td>
                    {% if perms.clariadmin.add_hosttype %}
                    <a id='add_id_{{ form.type.name }}' class="add-another" href="{% url admin:clariadmin_hosttype_add %}" onclick="return showAddAnotherPopup(this);">
                        <img width="10" height="10" alt="Ajouter un autre" src="{% admin_media_prefix %}img/admin/icon_addlink.gif" />
                    </a>{% endif %}
                </td>
            </tr>
            <tr>
                <th>{{ form.location.label_tag }}</th><td class="no_border">{{ form.location }}</td><td class="no_border">{{ form.location.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.serial.label_tag }}</th><td class="no_border">{{ form.serial }}</td><td class="no_border">{{ form.serial.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.inventory.label_tag }}</th><td class="no_border">{{ form.inventory }}</td><td class="no_border">{{ form.inventory.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.date_start_prod.label_tag }}</th><td class="no_border">{{ form.date_start_prod }}</td><td class="no_border">{{ form.date_start_prod.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.date_end_prod.label_tag }}</th><td class="no_border">{{ form.date_end_prod }}</td><td class="no_border">{{ form.date_end_prod.errors }}</td>
                <td></td>
            </tr>
            <tr>
                <th>{{ form.status.label_tag }}</th><td class="no_border">{{ form.status }}</td><td class="no_border">{{ form.status.errors }}</td>
                <td></td>
            </tr>
        </table>
    </fieldset>
    <fieldset id="{{ prefix }}extra_fieldset"{% if not additionnal_fields.fields %} class="dijitHidden"{% endif %}>
      <table id="{{ prefix }}extra_fields" class="clariadmin_form better">
        {% if additionnal_fields.fields %}
            {{ additionnal_fields }}
        {% else %}
            <tr><td></td></tr>
        {% endif %}
        </table>
    </fieldset>
    <hr class="clear" />
    {% if form.commentaire %}
    <table id="{{ prefix }}comment_table" class="clariadmin_form better">
        <tr>
            <th>{{ form.commentaire.label_tag }}:</th>
            <td>{{ form.commentaire }}</td>
            {% if form.commentaire.errors %}<td>{{ form.commentaire.errors }}</td>{% endif %}
        </tr>
    </table>
    {% endif %}
    <hr />
    {% if not ajax %}
    <div id="save_buttons">
      {% if host %}<button dojoType="dijit.form.Button" onclick='confirmDialog("Supression de l hote", "Êtes vous sûr de vouloir supprimer cette machine de la base?", confirmation_callback, "the_{{ prefix }}_form")'
          iconClass="dijitEditorIcon dijitEditorIconDelete" type="button" value="true" class="default">Suprimer</button>{% endif %}
        
      {% if perms.etiquette_printer.print_etiquettetemplate %}
      <button dojoType="dijit.form.Button" id="etiquette_button"  type="button"
              iconClass="dijitEditorIcon claritickEtiquettePrintIcon" 
              onClick='get_print_dialog("{% url etiquette_printer.print %}", "clariadmin", "Host", "{{ form.instance.id }}").show();'>Etiquette</button>
      {% endif %}
      
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconUndo" type="button" onclick='window.location = ".."'>Retourner à la liste</button>
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconSave" type="submit" name="submit_button" value="save">Enregistrer</button>
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconNewPage" type="submit" name="submit_button" value="new">Enregistrer et ajouter un nouveau</button>
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconRightToLeft" type="submit" name="submit_button" value="return">Enregistrer et retourner à la liste</button>
      <div class="right_buttons">
        <div dojoType="dijit.form.Button" iconClass="dijitEditorIcon claritickTicketMailAction" id="id_trace_button" onClick="window.location = '{% url list_logs "host" form.instance.id %}';">Historique</div>
        <div dojoType="dijit.Tooltip" connectId="id_trace_button">Voir l'historique de cette machine.</div>
      </div>
    </div>
    {% else %}
     <div>
       <button dojoType="dijit.form.Button" onclick='confirmDialog("Supression de l hote", "Êtes vous sûr de vouloir supprimer cette machine de la base?", confirmation_callback, "{% url modify_host prefix %}")'
           iconClass="dijitEditorIcon dijitEditorIconDelete" type="button" value="true" class="default">Suprimer</button>
      <button dojoType="dijit.form.Button" iconClass="dijitEditorIcon dijitEditorIconSave" type="submit" name="submit_button" value="save">Enregistrer</button>
      <div class="right_buttons">
        <div dojoType="dijit.form.Button" iconClass="dijitEditorIcon claritickTicketMailAction" id="{{ prefix }}id_trace_button" onClick="window.location = '{% url list_logs "host" form.instance.id %}';">Historique</div>
        <div dojoType="dijit.Tooltip" connectId="{{ prefix }}id_trace_button">Voir l'historique de cette machine.</div>
      </div>
    </div>
    {% endif %}
  </div>
</form>
